package com.jml.mapreduce.自定义OutputFormate;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * 泛型的来源是reduce，输入和输出格式都不变，所以这里的泛型应该和输入格式一样。
 */
public class MyOutputFormat extends FileOutputFormat<LongWritable, Text> {

    /**
     * 返回一个处理数据的Record Writer
     */
    @Override
    public RecordWriter<LongWritable, Text> getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException {
        return new MyRecordWriter(job);
    }
}
